/* -------------------------------------- 

     Cherrypy webapp skeleton frontend

     License: LGPL
     Authors: saaj (mail@saaj.me)

   -------------------------------------- */

/**
 * Abstract editor model class
 */
qx.Class.define("webapp.model.AbstractEditor", {

  extend : qx.core.Object,
  type   : "abstract",

  events : {

    /**
     *  Fired when model data loaded
     */
  	loaded : "qx.event.type.Data",
    
    /**
     *  Fired when model data saved
     */
  	saved : "qx.event.type.Data"
    
  },
  
  construct : function(serviceName)
  {
    this.base(arguments);

    this._serviceName = serviceName;
  },

  members : {

    _item        : null,
    _formModel   : null,
    _serviceName : null, 


    _createFormModel : function()
    {
    	throw new Error("Must be overriden in descendent class");
    },

    getFormModel : function()
    {
      return this._formModel;
    },

    load : function(item)
    {
      this._item      = item;
      this._formModel = null;
      
      this._createFormModel();
    },

    save : function()
    {
      throw new Error("Must be overriden in descendent class");
    }

  }

});